package com.chance.cc.crawler.development.bootstrap.weibo.ads;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.HttpConfig;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;

import java.text.ParseException;

import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.*;

/**
 * @ClassName weibo
 * @Description TODO
 * @Author songding
 * @Date 2021/9/28 11:06
 * @Version 1.0
 **/
public class WeiboUserStart {
    private static final String domain = "weibo";
    private static final String site = "user";
    public static void main(String[] args) {
        limit();
    }

    public static void limit(){
        String url = "https://weibo.com/u/7384381122";
        //String url = "https://weibo.com/u/2789987841";
        CrawlerRequestRecord requestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl(url)
                .httpConfig(HttpConfig.me(domain))
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.dateRange)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.article)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.interaction)
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24*7,null))
                .build();

        requestRecord.tagsCreator().bizTags().addDomain(domain);
        requestRecord.tagsCreator().bizTags().addSite(site);
        //关键词
        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest("keyword",turnPageItem)
                .httpUrl("")
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();

        DevCrawlerController.builder()
                .triggerInfo(domain,domain,System.currentTimeMillis(),domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline()
                .fileResultPipeline("F:\\chance_log\\weibo\\data.log",true)
                .requestRecord(requestRecord)
                //.supportRecord(keywordRecord)
                .build("com.chance.cc.crawler.development.scripts.weibo")
                .start();
    }
    @Test
    public void tt(){
        try {
            Long releaseTime = DateUtils.parseDate("2021-12-01 14:25", "yyyy-MM-dd HH:mm").getTime();
            System.out.println(releaseTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
